<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp"%>
<script type="text/javascript" >

$(function(){
	$('#officeGrid').datagrid({
	    url: ctx + '/mat/Office!findByPage.action',
	    fit: true,
	    pagination: true,
	    queryParams:{},
	    rownumbers: true,
	    toolbar:'#button_index',
	    idField: 'sid',
	    onDblClickRow :function(rowIndex,rowData){
	    	
	    }
	});
	
	$('#officeAdd').bind('click',function(){
		CQOA.load('extendDiv',ctx+'/mat/Office!operate.action',{},function(){
			CQOA.hideDiv('mainDiv');
			CQOA.showDiv('extendDiv');
		});
	});
	
	$('#officeEdit').bind('click',function(){
		var row = $('#officeGrid').datagrid('getSelected');
		if (!row) {
			$.messager.show({
				msg : '请选择一条数据'
			});
			return false;
		}
		CQOA.load('extendDiv',ctx+'/mat/Office!operate.action',{'entity.sid':row.sid},function(){
			CQOA.hideDiv('mainDiv');
			CQOA.showDiv('extendDiv');
		});
	});
	
	
	$('#officeDel').bind('click',function(){
		var row = $('#officeGrid').datagrid('getSelected');
			if (!row) {
				$.messager.show({
					msg : '请选择一条数据'
				});
				return false;
			}
			$.messager.confirm('提示信息','你确定要删除这条数据?',function(o){
				if(o){
					postcommit(ctx+'/mat/Office!delete.action',{'entity.sid':row.sid},function(rel){
						if(rel.success){
							$('#officeGrid').datagrid('reload');
						}
						$.messager.show({
							msg : rel.msg
						});
					});
				}
			});
		
	});
	$('#stitle').searchbox({
	    searcher:function(value,name){
	    	$('#officeGrid').datagrid('reload',{
	    		'entity.cname':value
	    	});
	    },
	    prompt:'请输入名称'
	});
	
});

function comeback(){
	CQOA.hideDiv('extendDiv');
	CQOA.showDiv('mainDiv');
};

function pffice_save(){
	CQOA.formSubmit($('#officeOperateForm'),ctx+'/mat/Office!save.action',function(o){
		if(o.success){
			comeback();
			$('#officeGrid').datagrid('reload');
		}
		$.messager.show({
			msg : o.msg
		});
	},{});
};

</script>
<div id="mainDiv" class="easyui-layout" fit="true" border="false">
	        <div id="easyui-title" style="display:none">
	            	办公用品管理
	        </div>
           <div class="top_toolbar_div" region="north" border="false">                
               <input id="stitle" style="width:300px" ></input>
            </div>
             <div id="button_index" class="top_toolbar_button_div" border="false">
              		<a href="#" class="easyui-linkbutton" id="officeAdd">新增</a>
                    <a href="#" class="easyui-linkbutton" id="officeEdit">修改</a>
                    <a href="#" class="easyui-linkbutton" id="officeDel">删除</a>
                </div>
            <div  region="center" border="false">
	           <table id="officeGrid" title="办公用品" border="false" fit="true" >
	               			<thead>
			                   <tr>
			                   	  <!-- 
			                      <th field="sid"  width="50">SID</th>
			                       -->
			                      <th field="cname"  width="100">名称</th>
			                      <th field="snSpec"  width="200">规格</th>
			                      <th field="snNumber"  width="150">剩余数量</th>
			                   </tr>
	               			</thead>
	       	 	</table>
           </div>
</div>
<div id="extendDiv" class="easyui-panel" style="display:none;" fit="true" border="false"></div>


